﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Protegidos/Pessoas/GENTE_Pes.master" AutoEventWireup="true" CodeFile="prAdvertencias.aspx.cs" Inherits="Protegidos_Pessoas_Relatorios_prAdvertencias" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content2" ContentPlaceHolderID="cphSubConteudo" Runat="Server">

<script type="text/javascript">
    var cancelDropDownClosing = false;

    /* <![CDATA[ */

    function StopPropagation(e) {
        //cancel bubbling
        e.cancelBubble = true;
        if (e.stopPropagation) {
            e.stopPropagation();
        }
    }

    function onDropDownClosing() {
        cancelDropDownClosing = false;
    }

    function onCheckBoxClick(chk) {
        var combo = $find("<%= rcbTipoSuspensao.ClientID %>");
        //prevent second combo from closing
        cancelDropDownClosing = true;
        //holds the text of all checked items
        var text = "";
        //holds the values of all checked items
        var values = "";
        //get the collection of all items
        var items = combo.get_items();

        //enumerate all items
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            //get the checkbox element of the current item
            var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
            if (chk1.checked) {
                text += item.get_text() + ",";
                values += item.get_value() + ",";
            }
        }
        //remove the last comma from the string
        text = removeLastComma(text);
        values = removeLastComma(values);

        if (text.length > 0) {
            //set the text of the combobox
            combo.set_text(text);
        }
        else {
            //all checkboxes are unchecked
            //so reset the controls        
            combo.set_text("")
        }
    }

    //this method removes the ending comma from a string
    function removeLastComma(str) {
        return str.replace(/,$/, "");
    }

    /* ]]> */
</script>

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="rgAdvertencias" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>      
    <telerik:AjaxSetting AjaxControlID="rgAdvertencias">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="rgAdvertencias" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>                                                             
</AjaxSettings>
</telerik:RadAjaxManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Telerik" >
</telerik:RadAjaxLoadingPanel> 

<table width="99%" align="center">
    <tr>
        <td>
            <div class="Titulo01">Advertências/Suspensões</div>
            <div class="Titulo02">Relatórios</div>
        </td>
    </tr>
    
    <tr>
        <td>
        
            <!-- INICIO - Pesquisa -->
            <table width="99%" align="right">
                <tr>
                    <td>
                        <div class="SuTituloVR">Dados de Pesquisa</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td style="width: 150px"><span class="textoCZ_12">Tipo:</span></td>
                                <td>
                                    <telerik:RadComboBox ID="rcbTipoSuspensao" runat="server" Skin="Telerik" DataTextField="Descricao" Font-Names="Verdana"
                                            DataValueField="IdTipoSuspensao" EmptyMessage="Todos" HighlightTemplatedItems="true"
                                            AllowCustomText="true" Width="240px" OnClientDropDownClosed="onDropDownClosing">
                                        <ItemTemplate>
                                            <div onclick="StopPropagation(event)">
                                                <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)" />
                                                <asp:Label runat="server" ID="lblDescricao" AssociatedControlID="chk1"><%# Eval("Descricao")%></asp:Label>
                                            </div>
                                        </ItemTemplate>      
                                    </telerik:RadComboBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px"><span class="textoCZ_12">Período Inicial:</span></td>
                                <td>
                                    <telerik:RadDatePicker ID="rdpPeriodoInicial" runat="server" Skin="Telerik" DateInput-Font-Names="Verdana">
                                        <DateInput DateFormat="dd/MM/yyyy"></DateInput>
                                    </telerik:RadDatePicker>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px"><span class="textoCZ_12">Período Final:</span></td>
                                <td>
                                    <telerik:RadDatePicker ID="rdpPeriodoFinal" runat="server" Skin="Telerik" DateInput-Font-Names="Verdana">
                                        <DateInput DateFormat="dd/MM/yyyy"></DateInput>
                                    </telerik:RadDatePicker>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                    <br />
                        <asp:Label ID="lblResultado" runat="server" Text=""></asp:Label>
                        <asp:Button ID="btnPesquisar" runat="server" Text="Pesquisar" Width="110px" onclick="btnPesquisar_Click" />&nbsp;&nbsp;
                        <asp:Button ID="btnLimpar" runat="server" Text="Limpar" Width="110px" onclick="btnLimpar_Click" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    
    <tr runat="server" id="trResultado">
        <td>
            
            <table width="99%" align="right">
                <tr>
                    <td>
                        <div class="SuTituloVR">Resultado da Pesquisa</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <telerik:RadGrid ID="rgAdvertencias" Width="100%" Skin="Telerik" 
                            runat="server" AllowPaging="true" AllowSorting="true" 
                            GridLines="None"  AutoGenerateColumns="false" PageSize="20"
                            OnNeedDataSource="rgAdvertencias_NeedDataSource">
                            <MasterTableView GridLines="None" DataKeyNames="IdAdvertencia" Name="TableViewAdvertencias">
                                <Columns>

                                    <telerik:GridBoundColumn UniqueName="Matricula" HeaderText="Matrícula" DataField="Pessoa.Matricual" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="Nome" HeaderText="Nome" DataField="Pessoa.NomeCompleto" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="AdvertidoPor" HeaderText="Advertido/Suspenso por" DataField="AdvertidoPor.NomeCompleto" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="DataAdvertencia" HeaderText="Em" DataField="DataAdvertencia" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="DataInicioSuspensao" HeaderText="Início Suspensão" DataField="DataInicioSuspensao" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="DataFimSuspensao" HeaderText="Retorno em" DataField="DataFimSuspensao" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="Obs" HeaderText="Descrição" DataField="Obs" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    
                                    <telerik:GridHyperLinkColumn DataTextFormatString="Visualizar"
                                        DataNavigateUrlFields="Path" UniqueName="Path" DataNavigateUrlFormatString="http://localhost/gentev1/{0}" Target="_blank"
                                        HeaderText="Imagem" DataTextField="Path">
                                    </telerik:GridHyperLinkColumn>
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>                        
                    </td>
                </tr>
            </table>
            
        </td>
    </tr>
    
</table>

</asp:Content>

